home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 2.2 / SetInspector.st < prev    next >
Text File  |  1993-07-24  |  3KB  |  140 lines

  1. "    NAME        SetInspector
  2.     AUTHOR        tph@cs.man.ac.uk
  3.     FUNCTION sensible version 
  4.     ST-VERSIONS    2.2
  5.     PREREQUISITES     
  6.     CONFLICTS    
  7.     DISTRIBUTION      world
  8.     VERSION        1.1
  9.     DATE    22 Jan 1989
  10. SUMMARY    SetInspector
  11.     extends the inspector to work sensibly for Sets.  This
  12.    goodie is based on a version which appeared on Usenet.(2.2).TPH
  13. "!
  14. Inspector subclass: #SetInspector
  15.     instanceVariableNames: 'topView listView '
  16.     classVariableNames: 'NoSelectionMenu YesSelectionMenu '
  17.     poolDictionaries: ''
  18.     category: 'Interface-SetInspector'!
  19.  
  20.  
  21. !SetInspector methodsFor: 'initialization'!
  22.  
  23. listView: aView 
  24.     ^listView _ aView!
  25.  
  26. topView: aView 
  27.     ^topView _ aView! !
  28.  
  29. !SetInspector methodsFor: 'field list'!
  30.  
  31. fieldMenu
  32.     field == nil
  33.         ifTrue: 
  34.             [NoSelectionMenu == nil ifTrue: [NoSelectionMenu _ ActionMenu labels: 'first non-empty' selectors: #(firstNonEmpty )].
  35.             ^NoSelectionMenu]
  36.         ifFalse: 
  37.             [YesSelectionMenu == nil ifTrue: [YesSelectionMenu _ ActionMenu
  38.                             labels: 'inspect\prev non-empty\next non-empty' withCRs
  39.                             lines: #(1 )
  40.                             selectors: #(inspectField prevNonEmpty nextNonEmpty )].
  41.             ^YesSelectionMenu]! !
  42.  
  43. !SetInspector methodsFor: 'menu commands'!
  44.  
  45. firstNonEmpty
  46.     1 to: object basicSize do: [:i | (object basicAt: i)
  47.             ~= nil
  48.             ifTrue: 
  49.                 [listView moveSelectionBox: i + 2.
  50.                 listView changeModelSelection: i + 2.
  51.                 ^self]].
  52.     topView flash!
  53.  
  54. nextNonEmpty
  55.     | idx |
  56.     field first isDigit ifFalse: [^self firstNonEmpty].
  57.     idx _ Integer readFromString: field.
  58.     idx + 1 to: object basicSize do: [:i | (object basicAt: i)
  59.             ~= nil
  60.             ifTrue: 
  61.                 [listView moveSelectionBox: i + 2.
  62.                 listView changeModelSelection: i + 2.
  63.                 ^self]].
  64.     topView flash!
  65.  
  66. prevNonEmpty
  67.     | idx |
  68.     field first isDigit ifFalse: [^self firstNonEmpty].
  69.     idx _ Integer readFromString: field.
  70.     idx - 1
  71.         to: 1
  72.         by: -1
  73.         do: [:i | (object basicAt: i)
  74.                 ~= nil
  75.                 ifTrue: 
  76.                     [listView moveSelectionBox: i + 2.
  77.                     listView changeModelSelection: i + 2.
  78.                     ^self]].
  79.     topView flash! !
  80. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  81.  
  82. SetInspector class
  83.     instanceVariableNames: ''!
  84.  
  85.  
  86. !SetInspector class methodsFor: 'initialization'!
  87.  
  88. flushMenus
  89.     YesSelectionMenu _ NoSelectionMenu _ nil! !
  90.  
  91. InspectorView subclass: #SetInspectorView
  92.     instanceVariableNames: ''
  93.     classVariableNames: ''
  94.     poolDictionaries: ''
  95.     category: 'Interface-SetInspector'!
  96.  
  97. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  98.  
  99. SetInspectorView class
  100.     instanceVariableNames: ''!
  101.  
  102.  
  103. !SetInspectorView class methodsFor: 'instance creation'!
  104.  
  105. view: anInspector in: area of: superView 
  106.     "Create proportioned List and Code views on anInspector in area of 
  107.     superView "
  108.  
  109.     | mid |
  110.     mid _ area left + (area width * 0.3).
  111.     anInspector topView: superView.
  112.     superView
  113.         addSubView: (anInspector listView: (SelectionInListView
  114.                     on: anInspector
  115.                     printItems: anInspector printItems
  116.                     oneItem: false
  117.                     aspect: #field
  118.                     change: #field:
  119.                     list: #fieldList
  120.                     menu: #fieldMenu
  121.                     initialSelection: #field))
  122.         in: (area copy right: mid)
  123.         borderWidth: 1.
  124.     superView
  125.         addSubView: (CodeView
  126.                 on: anInspector
  127.                 aspect: #text
  128.                 change: #acceptText:from:
  129.                 menu: #textMenu
  130.                 initialSelection: nil)
  131.         in: (area copy left: mid)
  132.         borderWidth: 1! !'From Smalltalk-80, version 2, of April 1, 1983 on 23 June 1987 at 7:25:59 pm'!
  133.  
  134.  
  135.  
  136. !Set methodsFor: 'user interface'!
  137.  
  138. inspect
  139.     SetInspectorView open: (SetInspector inspect: self)! !
  140.